#include "addroomdialog.h"
#include "ui_addroomdialog.h"

addRoomDialog::addRoomDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::addRoomDialog)
{
    ui->setupUi(this);
    
    ui->lineEdit->setText("新建房间");
    
    connect(ui->cancelBtn, SIGNAL(clicked(bool)), this, SLOT(close()));
    connect(ui->lineEdit, SIGNAL(textChanged(QString)), SLOT(updateBtn()));
    connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(getRoomName()));
    connect(ui->OKBtn, SIGNAL(clicked(bool)), this, SLOT(accept()));
}

addRoomDialog::~addRoomDialog()
{
    delete ui;
}

void addRoomDialog::updateBtn()
{
    if(ui->lineEdit->text().isEmpty())
        ui->OKBtn->setEnabled(false);
    else {
        ui->OKBtn->setEnabled(true);
    }
}

void addRoomDialog::getRoomName()
{
    if(!ui->lineEdit->text().isEmpty())
        roomName = ui->lineEdit->text();
}
